class Solution
{
public:
    int work(vector<int> &nums, int start)
    {
        int res = 0;
        for (int i = start; i < nums.size(); i += 2)
        {
            int t = nums[i];
            if (i - 1 >= 0) t = min(t, nums[i - 1] - 1);
            if (i + 1 < nums.size()) t = min(t, nums[i + 1] - 1);
            res += nums[i] - t;
        }
        return res;
    }

    int movesToMakeZigzag(vector<int> &nums)
    {
        return min(work(nums, 0), work(nums, 1));//以偶数为波峰和以奇数为波底,0为第一个数开始,1为第二个为开始
    }
};

//偶数位置大于相邻两个数,要么奇数位置比相邻两个数字大
//枚举奇数位置为波峰和枚举偶数位置为波峰